package com.reborn.mall.api.model.vo;

import com.reborn.mall.api.common.constant.StatusCode;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * 服务器响应基类
 *
 * @author wu.yue
 * @since 2020/2/6
 */
@Data
@AllArgsConstructor
public class BaseResponseVO<T> implements Serializable {
    private int code;
    private String message;
    private T data;

    private static <T> BaseResponseVO<T> data(StatusCode statusCode, T data) {
        return new BaseResponseVO<>(statusCode.getCode(), statusCode.getMessage(), data);
    }

    public static <T> BaseResponseVO<T> data(T data) {
        return BaseResponseVO.data(StatusCode.OK, data);
    }
}
